﻿using System;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections.Generic;
using System.Text;
using Texfina.Core.Common;
using Texfina.Common.Mg;
using Texfina.Core.Web;
using Texfina.Core.Data;
using Texfina.Entity.Rh;
using Texfina.Entity.Mg;
using Texfina.Entity.Sy;
using RHBOQry = Texfina.BOQry.Rh;
using MGBOQry = Texfina.BOQry.Mg;
using RHBOMnt = Texfina.BOMnt.Rh;
using SYBOQry = Texfina.BOQry.Sy;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;

namespace RH
{
   public partial class wfVeriPersonalMnt : EditPage
   {
      /// <summary>
      /// Guarda el estado de un DataTable, se usa para las remuneraciones del personal
      /// </summary>
      /// <value></value>
      /// <returns></returns>
      public DataTable DataSourceRem
      {
         get { return (DataTable)this.ViewState["_dsRem"]; }
         set { this.ViewState["_dsRem"] = value; }
      }

      /// <summary>
      /// Guarda el Indice del Registro en Edicion en un GridView
      /// </summary>
      /// <value></value>
      /// <returns></returns>
      public int EditRowIndexRem
      {
         get { return Convert.ToInt32(this.ViewState["_erowIdxRem"]); }
         set { this.ViewState["_erowIdxRem"] = value.ToString(); }
      }

      public GridEditAction GridEditActionRem
      {
         get { return (GridEditAction)this.ViewState["_gridEditRem"]; }
         set { this.ViewState["_gridEditRem"] = value; }
      }

      /// <summary>
      /// Guarda la Bandera para Aprobacion u Observacion
      /// </summary>
      /// <value></value>
      /// <returns></returns>
      public int intAprobObs
      {
         get { return Convert.ToInt32(this.ViewState["_intAprovObs"]); }
         set { this.ViewState["_intAprovObs"] = value.ToString(); }
      }

      public const int _GRDLIST_STANULADOREM = 6;
      public const int _INTMNUAPROBADO = 0;
      public const int _INTMNUOBSERVADO = 1;

      public string _STFOTO
      {
         get { return (string)this.ViewState["_STFOTO"]; }
         set { this.ViewState["_STFOTO"] = value; }
      }

      protected void Page_Load(object sender, EventArgs e)
      {
         if (this.IsPostBack)
         {
            this.LoadInPostBack();
            return;
         }
         this.LoadData();
      }

      public override void LoadInPostBack()
      {
         this.RegisterGeneralScripts();
      }

      public override void LoadInitialSettings()
      {
         this.FormEditAction = (FormEditAction)Enum.Parse(typeof(FormEditAction), Request.QueryString["formEA"]);
         Label lbl = (Label)this.Master.FindControl("lblTitle");
         lbl.Text = "Verificar Personal";
         this.intAprobObs = _INTMNUAPROBADO;
      }

      public override void LoadListControls()
      {
         ETablaGenDet objEDet = new ETablaGenDet();
         ETablaPEDet objEDetPE = new ETablaPEDet();
         ECCosto objECCosto = new ECCosto();
         EEmpEstable objEEmp = new EEmpEstable();
         EBanco objEBanco = new EBanco();
         EUNegocio objEUNeg = new EUNegocio();

         IBOQuery objBOUNego = (IBOQuery)WCFHelper.GetObject<IBOQuery>(typeof(MGBOQry.UNegocio));
         IBOQuery objBOCCosto = (IBOQuery)WCFHelper.GetObject<IBOQuery>(typeof(MGBOQry.CCosto));
         IBOQuery objBOBanco = (IBOQuery)WCFHelper.GetObject<IBOQuery>(typeof(MGBOQry.Banco));
         MGBOQry.ITablaGen objBOI = (MGBOQry.ITablaGen)WCFHelper.GetObject<MGBOQry.ITablaGen>(typeof(MGBOQry.TablaGen));
         RHBOQry.ITablaPE objBOIPE = (RHBOQry.ITablaPE)WCFHelper.GetObject<RHBOQry.ITablaPE>(typeof(RHBOQry.TablaPE));
         SYBOQry.IEmpresa objBOEmp = (SYBOQry.IEmpresa)WCFHelper.GetObject<SYBOQry.IEmpresa>(typeof(SYBOQry.Empresa));

         objEDet.IdTabla = ConstMultitabla.TIPO_DOCUMENTO;
         DataTable dt = objBOI.GetDetailByList(objEDet);
         WebHelper.LoadListControl(ddlidTDocIden, dt, "dsAbrev", "idCodigo", true, true);

         objEDet.IdTabla = ConstMultitabla.CATEGORIA_TRABAJADOR;
         dt = objBOI.GetDetailByList(objEDet);
         WebHelper.LoadListControl(ddlidCateTrab, dt, "dsDescrip", "idCodigo", true, true);

         objEDet.IdTabla = ConstMultitabla.TIPO_COLABORADOR;
         dt = objBOI.GetDetailByList(objEDet);
         WebHelper.LoadListControl(ddlidTipoTrab, dt, "dsDescrip", "idCodigo", true, true);

         objEDet.IdTabla = ConstMultitabla.SEXO;
         dt = objBOI.GetDetailByList(objEDet);
         WebHelper.LoadListControl(ddlidSexo, dt, "dsDescrip", "idCodigo", true, true);

         objEDet.IdTabla = ConstMultitabla.TIPO_VIA;
         dt = objBOI.GetDetailByList(objEDet);
         WebHelper.LoadListControl(ddlidTipoVia, dt, "dsDescrip", "idCodigo", true, true);

         objEDet.IdTabla = ConstMultitabla.CATEGORIA_OCUPACIONAL;
         dt = objBOI.GetDetailByList(objEDet);
         WebHelper.LoadListControl(ddlidCateOcup, dt, "dsDescrip", "idCodigo", true, true);

         objEDet.IdTabla = ConstMultitabla.REGIMEN_LABORAL;
         dt = objBOI.GetDetailByList(objEDet);
         WebHelper.LoadListControl(ddlidRegLaboral, dt, "dsDescrip", "idCodigo", true, true);

         objEDet.IdTabla = ConstMultitabla.NIVEL_EDUCATIVO;
         dt = objBOI.GetDetailByList(objEDet);
         WebHelper.LoadListControl(ddlidNivEduc, dt, "dsDescrip", "idCodigo", true, true);

         objEDet.IdTabla = ConstMultitabla.REGIME_PENSIONARIO;
         dt = objBOI.GetDetailByList(objEDet);
         WebHelper.LoadListControl(ddlidRegPensi, dt, "dsDescrip", "idCodigo", true, true);

         objEDet.IdTabla = ConstMultitabla.SEGURO_MEDICO;
         dt = objBOI.GetDetailByList(objEDet);
         WebHelper.LoadListControl(ddlidSctrSalud, dt, "dsDescrip", "idCodigo", true, true);

         objEDet.IdTabla = ConstMultitabla.SEGURO_PENSION;
         dt = objBOI.GetDetailByList(objEDet);
         WebHelper.LoadListControl(ddlidSctrPens, dt, "dsDescrip", "idCodigo", true, true);

         objEDet.IdTabla = ConstMultitabla.TIPO_CONTRATO;
         dt = objBOI.GetDetailByList(objEDet);
         WebHelper.LoadListControl(ddlidTipoCont, dt, "dsDescrip", "idCodigo", true, true);

         objEDet.IdTabla = ConstMultitabla.PERIODO_REMUNERACION;
         dt = objBOI.GetDetailByList(objEDet);
         WebHelper.LoadListControl(ddlidPeriRemu, dt, "dsDescrip", "idCodigo", true, true);

         objEDet.IdTabla = ConstMultitabla.CENTRO_FORMACION;
         dt = objBOI.GetDetailByList(objEDet);
         WebHelper.LoadListControl(ddlidCentroFP, dt, "dsDescrip", "idCodigo", true, true);

         objEDet.IdTabla = ConstMultitabla.EMPRESA_PRESTADORA_EPS;
         dt = objBOI.GetDetailByList(objEDet);
         WebHelper.LoadListControl(ddlidEmpEps, dt, "dsDescrip", "idCodigo", true, true);

         objEDet.IdTabla = ConstMultitabla.SITUACION_TRABAJADOR;
         dt = objBOI.GetDetailByList(objEDet);
         WebHelper.LoadListControl(ddlidSituEmple, dt, "dsDescrip", "idCodigo", true, true);

         objEDet.IdTabla = ConstMultitabla.TIPO_REMUNERACION;
         dt = objBOI.GetDetailByList(objEDet);
         WebHelper.LoadListControl(ddlidTipoRemu, dt, "dsDescrip", "idCodigo", true, true);

         objEDet.IdTabla = ConstMultitabla.MOTIVO_CESE;
         dt = objBOI.GetDetailByList(objEDet);
         WebHelper.LoadListControl(ddlidMotivFin, dt, "dsDescrip", "idCodigo", true, true);

         objEDet.IdTabla = ConstMultitabla.TIPO_MODALIDAD_FORMATIVA;
         dt = objBOI.GetDetailByList(objEDet);
         WebHelper.LoadListControl(ddlidTipoCenFP, dt, "dsDescrip", "idCodigo", true, true);

         objEDet.IdTabla = ConstMultitabla.ESTADO_CIVIL;
         dt = objBOI.GetDetailByList(objEDet);
         WebHelper.LoadListControl(ddlidEstaCivil, dt, "dsDescrip", "idCodigo", true, true);

         objEDet.IdTabla = ConstMultitabla.TIPO_CUENTA_BANCARIA;
         dt = objBOI.GetDetailByList(objEDet);
         WebHelper.LoadListControl(ddlidTipoCtaAbono, dt, "dsDescrip", "idCodigo", true, true);

         objEDet.IdTabla = ConstMultitabla.TIPO_ZONA;
         dt = objBOI.GetDetailByList(objEDet);
         WebHelper.LoadListControl(ddlidTipoZona, dt, "dsDescrip", "idCodigo", true, true);

         objEDet.IdTabla = ConstMultitabla.TIPO_SANGRE;
         dt = objBOI.GetDetailByList(objEDet);
         WebHelper.LoadListControl(ddlidTipoSangre, dt, "dsDescrip", "idCodigo", true, true);

         objEDet.IdTabla = ConstMultitabla.FORMA_PAGO;
         dt = objBOI.GetDetailByList(objEDet);
         WebHelper.LoadListControl(ddlidForPago, dt, "dsDescrip", "idCodigo", true, false);

         objEDet.IdTabla = ConstMultitabla.TIPO_REMUNERACION_BASICA;
         dt = objBOI.GetDetailByList(objEDet);
         WebHelper.LoadListControl(ddlidTipRemu, dt, "dsDescrip", "idCodigo", true, false);

         objEDet.IdTabla = ConstMultitabla.TIPO_MONEDA;
         dt = objBOI.GetDetailByList(objEDet);
         WebHelper.LoadListControl(ddlidMoneda, dt, "dsDescrip", "idCodigo", true, false);

         objEUNeg.IdEmpresa = Session[ConstSessionVar.EMPRESA].ToString();
         dt = objBOUNego.GetList(objEUNeg);
         WebHelper.LoadListControl(ddlidUNegocio, dt, "dsUNegocio", "idUNegocio", true, true);

         //objECCosto.IdEmpresa = Session[ConstSessionVar.EMPRESA].ToString();
         //dt = objBOCCosto.GetList(objECCosto);
         //WebHelper.LoadListControl(ddlidCCosto, dt, "dsCCosto", "idCCosto", true, true);

         objEEmp.IdEmpresa = Session[ConstSessionVar.EMPRESA].ToString();
         dt = objBOEmp.GetEstablecimientos(objEEmp);
         WebHelper.LoadListControl(ddlidEstable, dt, "dsEstable", "idEstable", true, true);

         objEBanco.IdBanco = "";
         dt = objBOBanco.GetList(objEBanco);
         WebHelper.LoadListControl(ddlidBcoAbono, dt, "dsBanco", "idBanco", true, true);
         WebHelper.LoadListControl(ddlidBcoCts, dt, "dsBanco", "idBanco", true, true);
      }

      public override void DataToControls()
      {
         EPersonal objE = new EPersonal();
         IBOQuery objBO = (IBOQuery)WCFHelper.GetObject<IBOQuery>(typeof(RHBOQry.Personal));
         objE.IdEmpresa = Session[ConstSessionVar.EMPRESA].ToString();
         objE.IdPersonal = Request.QueryString["IdPersonal"];
         objE = (EPersonal)objBO.GetByKey(objE);

         if (objE != null)
         {

            WebHelper.EntityToControl(objE, "IdPersonal", txtidPersonal);

            WebHelper.EntityToControl(objE, "IdUNegocio", ddlidUNegocio);

            ddlidCCosto.Items.Clear();
            EUNegocio objEUNeg = new EUNegocio();
            MGBOQry.IUNegocio objBOUNego = (MGBOQry.IUNegocio)WCFHelper.GetObject<MGBOQry.IUNegocio>(typeof(MGBOQry.UNegocio));
            objEUNeg.IdEmpresa = Session[ConstSessionVar.EMPRESA].ToString();
            objEUNeg.IdUNegocio = objE.IdUNegocio;
            DataTable dtA = objBOUNego.GetCCostoXUNegocio(objEUNeg);
            WebHelper.LoadListControl(ddlidCCosto, dtA, "dsCCosto", "idCCosto", true, true);

            WebHelper.EntityToControl(objE, "IdCCosto", ddlidCCosto);

            WebHelper.EntityToControl(objE, "FeNacimien", txtfeNacimiento);
            WebHelper.EntityToControl(objE, "IdSexo", ddlidSexo);

            ECliProv objECli = new ECliProv();
            IBOQuery objBOCli = (IBOQuery)WCFHelper.GetObject<IBOQuery>(typeof(MGBOQry.CliProv));
            objECli.IdCliProv = objE.IdCliProv;
            objECli = (ECliProv)objBOCli.GetByKey(objECli);

            if (objECli != null)
            {
               WebHelper.EntityToControl(objECli, "IdCliProv", hdnidCliProv);
               WebHelper.EntityToControl(objECli, "DsAPaterno", txtdsAPaterno);
               WebHelper.EntityToControl(objECli, "DsAMaterno", txtdsAMaterno);
               WebHelper.EntityToControl(objECli, "DsNombres", txtdsNombres);
               WebHelper.EntityToControl(objECli, "IdTDocIden", ddlidTDocIden);
               WebHelper.EntityToControl(objECli, "NuDocIden", txtnuDocIden);
               WebHelper.EntityToControl(objECli, "FeVenDocIden", txtfeVctoDoIde);

               EUbigeo objEUbi = new EUbigeo();
               MGBOQry.IUbigeo objBOUbi = (MGBOQry.IUbigeo)WCFHelper.GetObject<MGBOQry.IUbigeo>(typeof(MGBOQry.Ubigeo));
               objEUbi.IdPais = objECli.IdPais;
               objEUbi.IdDepa = objECli.IdDepa;
               objEUbi.IdProv = objECli.IdProv;
               objEUbi.IdDist = objECli.IdDist;
               DataTable dt = objBOUbi.GetDsUbigeoByKey(objEUbi);

               foreach (DataRow dr in dt.Rows)
               {
                  txtdsUbigeo.Text = dr["dsPais"].ToString() + "/" + dr["dsDepa"].ToString() + "/" + dr["dsProv"].ToString() + "/" + dr["idDist"].ToString();
                  hdnidPais.Value = dr["idPais"].ToString();
                  hdnidDepa.Value = dr["idDepa"].ToString();
                  hdnidProv.Value = dr["idProv"].ToString();
                  hdnidDist.Value = dr["idDist"].ToString();
                  break;
               }

               WebHelper.EntityToControl(objECli, "IdTipoVia", ddlidTipoVia);
               WebHelper.EntityToControl(objECli, "DsNombreVia", txtdsNombreVia);
               WebHelper.EntityToControl(objECli, "NuVia", txtnuVia);
               WebHelper.EntityToControl(objECli, "NuDpto", txtnuDpto);
               WebHelper.EntityToControl(objECli, "NuInterior", txtnuInterior);
               WebHelper.EntityToControl(objECli, "DsManzana", txtdsManzana);
               WebHelper.EntityToControl(objECli, "DsLote", txtdsLote);
               WebHelper.EntityToControl(objECli, "DsKilometro", txtdsKilometro);
               WebHelper.EntityToControl(objECli, "DsBlock", txtdsBlock);
               WebHelper.EntityToControl(objECli, "DsEtapa", txtdsEtapa);
               WebHelper.EntityToControl(objECli, "IdTipoZona", ddlidTipoZona);
               WebHelper.EntityToControl(objECli, "DsNombZona", txtdsNombZona);
               WebHelper.EntityToControl(objECli, "DsReferen", txtdsReferen);
               WebHelper.EntityToControl(objECli, "NuTelf", txtnuTelf);
               WebHelper.EntityToControl(objECli, "NuFax", txtnufax);
               WebHelper.EntityToControl(objECli, "DsEmail", txtdsEmail);
               WebHelper.EntityToControl(objECli, "DsWeb", txtdsWeb);

               EPerContrato objEPerC = new EPerContrato();
               RHBOQry.Personal objBOPerC = (RHBOQry.Personal)WCFHelper.GetObject<RHBOQry.Personal>(typeof(RHBOQry.Personal));
               objEPerC.IdEmpresa = Session[ConstSessionVar.EMPRESA].ToString();
               objEPerC.IdPersonal = Request.QueryString["IdPersonal"];
               dt = objBOPerC.GetByParentKeyPerContrato(objEPerC);

               this.GridSetDataBinding(grdList, dt);

               EPerRemu objEPerRem = new EPerRemu();
               RHBOQry.Personal objBOPerRem = (RHBOQry.Personal)WCFHelper.GetObject<RHBOQry.Personal>(typeof(RHBOQry.Personal));
               objEPerRem.IdEmpresa = Session[ConstSessionVar.EMPRESA].ToString();
               objEPerRem.IdPersonal = Request.QueryString["IdPersonal"];
               objEPerRem.IdForPago = "";
               objEPerRem.IdTipoRemu = "";
               dt = objBOPerRem.GetByParentKeyPerRemuneracion(objEPerRem);

               this.DataSourceRem = dt;
               grdListRem.DataSource = this.DataSourceRem;
               grdListRem.DataBind();


            }

            WebHelper.EntityToControl(objE, "IdEstable", ddlidEstable);
            WebHelper.EntityToControl(objE, "NuFotocheck", txtnuFotocheck);
            WebHelper.EntityToControl(objE, "IdCateTrab", ddlidCateTrab);
            WebHelper.EntityToControl(objE, "IdCateOcupa", ddlidCateOcup);
            WebHelper.EntityToControl(objE, "IdRegLaboral", ddlidRegLaboral);
            WebHelper.EntityToControl(objE, "IdTipoTrab", ddlidTipoTrab);
            WebHelper.EntityToControl(objE, "IdNivEduc", ddlidNivEduc);
            WebHelper.EntityToControl(objE, "IdOcupa", txtidOcupa);

            EOcupacion objEOcu = new EOcupacion();
            IBOQuery objBOOcu = (IBOQuery)WCFHelper.GetObject<IBOQuery>(typeof(MGBOQry.Ocupacion));
            objEOcu.IdOcupa = objE.IdOcupa;
            objEOcu = (EOcupacion)objBOOcu.GetByKey(objEOcu);
            if (objEOcu != null)
               WebHelper.EntityToControl(objEOcu, "DsOcupa", txtdsOcupa);
            WebHelper.EntityToControl(objE, "IdRegPensi", ddlidRegPensi);
            WebHelper.EntityToControl(objE, "FeInscRegPen", txtfeInsRegPen);
            WebHelper.EntityToControl(objE, "NuCuspp", txtnuCuspp);
            WebHelper.EntityToControl(objE, "IdSctrSalud", ddlidSctrSalud);
            WebHelper.EntityToControl(objE, "IdSctrPens", ddlidSctrPens);
            WebHelper.EntityToControl(objE, "IdTipoCont", ddlidTipoCont);
            WebHelper.EntityToControl(objE, "IdPeriRemu", ddlidPeriRemu);
            WebHelper.EntityToControl(objE, "IdEmpEps", ddlidEmpEps);
            WebHelper.EntityToControl(objE, "IdSituEmple", ddlidSituEmple);
            WebHelper.EntityToControl(objE, "IdTipoRemu", ddlidTipoRemu);
            WebHelper.EntityToControl(objE, "FeIngpla", txtfeIngPla);
            WebHelper.EntityToControl(objE, "FeCese", txtfeCese);
            WebHelper.EntityToControl(objE, "IdMotivFin", ddlidMotivFin);
            WebHelper.EntityToControl(objE, "IdTipoCenFP", ddlidTipoCenFP);
            WebHelper.EntityToControl(objE, "IdCentroFP", ddlidCentroFP);
            WebHelper.EntityToControl(objE, "IdEstaCivil", ddlidEstaCivil);
            WebHelper.EntityToControl(objE, "IdBcoAbono", ddlidBcoAbono);
            WebHelper.EntityToControl(objE, "IdTipoCtaAbo", ddlidTipoCtaAbono);
            WebHelper.EntityToControl(objE, "NuCtaAbono", txtnuctaAbono);
            WebHelper.EntityToControl(objE, "IdBcoCts", ddlidBcoCts);
            WebHelper.EntityToControl(objE, "NuCtaCts", txtnuCtaCts);
            WebHelper.EntityToControl(objE, "StEsSalud", chkstEsSalud);
            WebHelper.EntityToControl(objE, "StDomiciliado", chkstDomiciliado);
            WebHelper.EntityToControl(objE, "StDiscapa", chkstDiscapa);
            WebHelper.EntityToControl(objE, "StSujRegAlter", chkstSujRegAlter);
            WebHelper.EntityToControl(objE, "StJTAtipico", chkstJTAtipico);
            WebHelper.EntityToControl(objE, "StJTMaxima", chkstJTMaxima);
            WebHelper.EntityToControl(objE, "StJTHoraNoc", chkstJTHoraNoc);
            WebHelper.EntityToControl(objE, "StOtrosIng5ta", chkstOtrosIng5ta);
            WebHelper.EntityToControl(objE, "StSindical", chkstSindical);
            WebHelper.EntityToControl(objE, "St5taExon", chkst5taExo);
            WebHelper.EntityToControl(objE, "StMadreResp", chkstMadreResp);
            WebHelper.EntityToControl(objE, "StAsigFami", chkstAsigFami);
            WebHelper.EntityToControl(objE, "IdTipoSangre", ddlidTipoSangre);
            WebHelper.EntityToControl(objE, "DsEnfermedad", txtdsEnfermedad);
            WebHelper.EntityToControl(objE, "DsAlergia", txtdsAlergia);
            WebHelper.EntityToControl(objE, "DsPriAuxilios", txtdsPriAuxilios);
            WebHelper.EntityToControl(objE, "NuTalla", txtnuTalla);
            WebHelper.EntityToControl(objE, "NuPeso", txtnuPeso);
            WebHelper.EntityToControl(objE, "DsTallaCalza", txtdsTallaCalza);
            WebHelper.EntityToControl(objE, "DsTallaPanta", txtdsTallaPanta);
            WebHelper.EntityToControl(objE, "DsTallaCamisa", txtdsTallaCamisa);
            WebHelper.EntityToControl(objE, "DsClubSoDe", txtdsClubSoDe);
            WebHelper.EntityToControl(objE, "DsHobby", txtdsHobby);
            WebHelper.EntityToControl(objE, "DsReligion", txtdsReligion);

         }

         EPerFoto objEPerFoto = new EPerFoto();
         RHBOQry.IPersonal objBOPerFoto = (RHBOQry.IPersonal)WCFHelper.GetObject<RHBOQry.IPersonal>(typeof(RHBOQry.Personal));
         objEPerFoto.IdEmpresa = Session[ConstSessionVar.EMPRESA].ToString();
         objEPerFoto.IdPersonal = Request.QueryString["IdPersonal"];
         objEPerFoto = (EPerFoto)objBOPerFoto.GetByKeyPerFoto(objEPerFoto);

         if (objEPerFoto != null)
         {
            this.imgidFotografia.ImageUrl = "MostrarImage.ashx?IdEmpresa=" + Session[ConstSessionVar.EMPRESA].ToString() + "&IdPersonal=" + Request.QueryString["IdPersonal"];
            _STFOTO = ConstFlagEstado.ACTIVADO;
            this.txtidFotografia.Text = objEPerFoto.DsNombreArch;
         }
         else
         {
            this.imgidFotografia.ImageUrl = "../Images/Controls/fuFotografia.png";
            _STFOTO = ConstFlagEstado.DESACTIVADO;
         }



      }

      public override void RegisterGeneralScripts()
      {
         this.txtidPersonal.Attributes.Add("readonly", "true");
         this.txtidFotografia.Attributes.Add("readonly", "true");
         this.txtidOcupa.Attributes.Add("readonly", "true");
         this.txtnuRUC.Attributes.Add("readonly", "true");
         //this.tabChildPrinci.Attributes.Add("disabled", "true");
         //this.tabChildDComple.Attributes.Add("disabled", "true");

         StringBuilder sb = new StringBuilder();

         sb.AppendLine("var varRet = modalDialog('../MG/wfUbigeoBnd.aspx',725,400);");
         sb.AppendLine("if(varRet==null)");
         sb.AppendLine("return false;");
         sb.AppendLine("ctl = document.getElementById('" + this.hdnidPais.ClientID + "');");
         sb.AppendLine("ctl.value = varRet[0];");
         sb.AppendLine("ctl = document.getElementById('" + this.hdnidDepa.ClientID + "');");
         sb.AppendLine("ctl.value = varRet[2];");
         sb.AppendLine("ctl = document.getElementById('" + this.hdnidProv.ClientID + "');");
         sb.AppendLine("ctl.value = varRet[4];");
         sb.AppendLine("ctl = document.getElementById('" + this.hdnidDist.ClientID + "');");
         sb.AppendLine("ctl.value = varRet[6];");
         sb.AppendLine("ctl = document.getElementById('" + this.txtdsUbigeo.ClientID + "');");
         sb.AppendLine("ctl.value = varRet[1] + ' / ' + varRet[3] + ' / ' + varRet[5] + ' / ' + varRet[7];");
         sb.AppendLine("ctl.title = ctl.value;");
         this.txtdsUbigeo.OnClientClick = sb.ToString();

         sb = new StringBuilder();

         sb.AppendLine("var varRet = modalDialog('../MG/wfOcupacionBnd.aspx',725,400);");
         sb.AppendLine("if(varRet==null)");
         sb.AppendLine("return false;");
         sb.AppendLine("ctl = document.getElementById('" + this.txtidOcupa.ClientID + "');");
         sb.AppendLine("ctl.value = varRet[0];");
         sb.AppendLine("ctl = document.getElementById('" + this.txtdsOcupa.ClientID + "');");
         sb.AppendLine("ctl.value = varRet[1];");
         this.txtdsOcupa.OnClientClick = sb.ToString();

         sb = new StringBuilder();

         sb.AppendLine("function validateEditForm(key){");
         sb.AppendLine("if(key=='" + ConstMenuToolbarValue.BUTTON_SAVEOK + "'){");

         sb.AppendLine("var varRpta = isEmptyControl('" + txtdsAPaterno.ClientID + "','Ingrese el Apellido Paterno');");
         sb.AppendLine("if(varRpta==true){");
         sb.AppendLine("document.getElementById('" + txtdsAPaterno.ClientID + "').focus();return !varRpta;}");
         sb.AppendLine("var varRpta = isEmptyControl('" + txtdsAMaterno.ClientID + "','Ingrese el Apellido Materno');");
         sb.AppendLine("if(varRpta==true){");
         sb.AppendLine("document.getElementById('" + txtdsAMaterno.ClientID + "').focus();return !varRpta;}");
         sb.AppendLine("var varRpta = isEmptyControl('" + txtdsNombres.ClientID + "','Ingrese los Nombres');");
         sb.AppendLine("if(varRpta==true){");
         sb.AppendLine("document.getElementById('" + txtdsNombres.ClientID + "').focus();return !varRpta;}");
         sb.AppendLine("var varRpta = isEmptyControl('" + ddlidTDocIden.ClientID + "','Seleccione el tipo de Documento de Identidad');");
         sb.AppendLine("if(varRpta==true){");
         sb.AppendLine("document.getElementById('" + ddlidTDocIden.ClientID + "').focus();return !varRpta;}");
         sb.AppendLine("var varRpta = isEmptyControl('" + txtnuDocIden.ClientID + "','Ingrese el numero de Documento de Identidad');");
         sb.AppendLine("if(varRpta==true){");
         sb.AppendLine("document.getElementById('" + txtnuDocIden.ClientID + "').focus();return !varRpta;}");
         sb.AppendLine("var varRpta = isEmptyControl('" + txtfeNacimiento.ClientID + "','Seleccione o ingrese la fecha de Nacimiento');");
         sb.AppendLine("if(varRpta==true){");
         sb.AppendLine("document.getElementById('" + txtfeNacimiento.ClientID + "').focus();return !varRpta;}");
         sb.AppendLine("var varRpta = isEmptyControl('" + ddlidSexo.ClientID + "','Seleccione el Genero');");
         sb.AppendLine("if(varRpta==true){");
         sb.AppendLine("document.getElementById('" + ddlidSexo.ClientID + "').focus();return !varRpta;}");
         sb.AppendLine("var varRpta = isEmptyControl('" + txtnuTelf.ClientID + "','Ingrese el numero de telefono');");
         sb.AppendLine("if(varRpta==true){");
         sb.AppendLine("document.getElementById('" + txtnuTelf.ClientID + "').focus();return !varRpta;}");
         sb.AppendLine("var varRpta = isEmptyControl('" + ddlidCCosto.ClientID + "','Seleccione el Centro de Costo');");
         sb.AppendLine("if(varRpta==true){");
         sb.AppendLine("document.getElementById('" + ddlidCCosto.ClientID + "').focus();return !varRpta;}");
         sb.AppendLine("var varRpta = isEmptyControl('" + ddlidEstable.ClientID + "','Seleccione el establecimiento');");
         sb.AppendLine("if(varRpta==true){");
         sb.AppendLine("document.getElementById('" + txtnuFotocheck.ClientID + "').focus();return !varRpta;}");
         sb.AppendLine("var varRpta = isEmptyControl('" + ddlidCateTrab.ClientID + "','Seleccione la categoria del trabajador');");
         sb.AppendLine("if(varRpta==true){");
         sb.AppendLine("document.getElementById('" + ddlidCateTrab.ClientID + "').focus();return !varRpta;}");
         sb.AppendLine("var varRpta = isEmptyControl('" + txtdsUbigeo.ClientID + "','Seleccione el Ubigeo');");
         sb.AppendLine("if(varRpta==true){");
         sb.AppendLine("document.getElementById('" + txtdsUbigeo.ClientID + "').focus();return !varRpta;}");
         sb.AppendLine("var varRpta = isEmptyControl('" + ddlidTipoVia.ClientID + "','Seleccione el tipo de via');");
         sb.AppendLine("if(varRpta==true){");
         sb.AppendLine("document.getElementById('" + ddlidTipoVia.ClientID + "').focus();return !varRpta;}");
         sb.AppendLine("var varRpta = isEmptyControl('" + txtdsNombreVia.ClientID + "','Ingrese el nombre de la via');");
         sb.AppendLine("if(varRpta==true){");
         sb.AppendLine("document.getElementById('" + txtdsNombreVia.ClientID + "').focus();return !varRpta;}");
         sb.AppendLine("var varRpta = isEmptyControl('" + ddlidTipoZona.ClientID + "','Seleccione el tipo de zona');");
         sb.AppendLine("if(varRpta==true){");
         sb.AppendLine("document.getElementById('" + ddlidTipoZona.ClientID + "').focus();return !varRpta;}");
         sb.AppendLine("var varRpta = isEmptyControl('" + txtdsNombZona.ClientID + "','Ingrese el nombre de la zona');");
         sb.AppendLine("if(varRpta==true){");
         sb.AppendLine("document.getElementById('" + txtdsNombZona.ClientID + "').focus();return !varRpta;}");
         sb.AppendLine("switch (document.getElementById('" + ddlidCateTrab.ClientID + "').value){");
         sb.AppendLine("case '" + ConstCategoriaTrab.TRABAJADOR + "':");
         sb.AppendLine("    var varRpta = isEmptyControl('" + ddlidTipoTrab.ClientID + "','Seleccione el tipo de Trabajador');");
         sb.AppendLine("    if(varRpta==true)");
         sb.AppendLine("    return !varRpta;");
         sb.AppendLine("    var ddlTipTrab = document.getElementById('" + ddlidTipoTrab.ClientID + "').value;");
         sb.AppendLine("    if(ddlTipTrab != '" + ConstTipoTrabajador.EMPLEADO + "' && ddlTipTrab != '" + ConstTipoTrabajador.EJECUTIVO + "' && ddlTipTrab != '" + ConstTipoTrabajador.OBRERO + "'){");
         sb.AppendLine("        var varRpta = isEmptyControl('" + ddlidTipoTrab.ClientID + "','Seleccione el tipo de Trabajador');");
         sb.AppendLine("        if(varRpta==true)");
         sb.AppendLine("        return !varRpta;}");
         sb.AppendLine("    var varRpta = isEmptyControl('" + ddlidRegLaboral.ClientID + "','Seleccione el regimen laboral');");
         sb.AppendLine("    if(varRpta==true)");
         sb.AppendLine("    return !varRpta;");
         sb.AppendLine("    var varRpta = isEmptyControl('" + ddlidNivEduc.ClientID + "','Seleccione el Nivel de Educacion');");
         sb.AppendLine("    if(varRpta==true)");
         sb.AppendLine("    return !varRpta;");
         sb.AppendLine("    var varRpta = isEmptyControl('" + txtdsOcupa.ClientID + "','Seleccione la Ocupacion.');");
         sb.AppendLine("    if(varRpta==true)");
         sb.AppendLine("    return !varRpta;");
         sb.AppendLine("    var varRpta = isEmptyControl('" + ddlidRegPensi.ClientID + "','Seleccione el regimen pensionario.');");
         sb.AppendLine("    if(varRpta==true)");
         sb.AppendLine("    return !varRpta;");
         sb.AppendLine("    var varRpta = isEmptyControl('" + txtfeInsRegPen.ClientID + "','Ingrese o seleccione la fecha de inscripcion.');");
         sb.AppendLine("    if(varRpta==true)");
         sb.AppendLine("    return !varRpta;");
         sb.AppendLine("    var varRpta = isEmptyControl('" + txtnuCuspp.ClientID + "','Ingrese el CUSPP.');");
         sb.AppendLine("    if(varRpta==true)");
         sb.AppendLine("    return !varRpta;");
         sb.AppendLine("    var varRpta = isEmptyControl('" + ddlidSctrSalud.ClientID + "','Seleccione el SCTR Salud.');");
         sb.AppendLine("    if(varRpta==true)");
         sb.AppendLine("    return !varRpta;");
         sb.AppendLine("    var varRpta = isEmptyControl('" + ddlidSctrPens.ClientID + "','Seleccione el SCTR Pension.');");
         sb.AppendLine("    if(varRpta==true)");
         sb.AppendLine("    return !varRpta;");
         sb.AppendLine("    var varRpta = isEmptyControl('" + ddlidTipoCont.ClientID + "','Seleccione el tipo de Contrato.');");
         sb.AppendLine("    if(varRpta==true)");
         sb.AppendLine("    return !varRpta;");
         sb.AppendLine("    var varRpta = isEmptyControl('" + ddlidSituEmple.ClientID + "','Seleccione la situacion del empleado.');");
         sb.AppendLine("    if(varRpta==true)");
         sb.AppendLine("    return !varRpta;");
         sb.AppendLine("    var varRpta = isEmptyControl('" + ddlidPeriRemu.ClientID + "','Seleccione el periodo de remuneracion.');");
         sb.AppendLine("    if(varRpta==true)");
         sb.AppendLine("    return !varRpta;");
         sb.AppendLine("    var varRpta = isEmptyControl('" + ddlidEstaCivil.ClientID + "','Seleccione el estado civil.');");
         sb.AppendLine("    if(varRpta==true)");
         sb.AppendLine("    return !varRpta;");
         sb.AppendLine("    var varRpta = isEmptyControl('" + ddlidTipoRemu.ClientID + "','Seleccione el tipo de remuneracion.');");
         sb.AppendLine("    if(varRpta==true)");
         sb.AppendLine("    return !varRpta;");
         sb.AppendLine("    break;");
         sb.AppendLine("case '" + ConstCategoriaTrab.PENSIONISTA + "':");
         sb.AppendLine("    var varRpta = isEmptyControl('" + ddlidTipoTrab.ClientID + "','Seleccione el tipo de Trabajador');");
         sb.AppendLine("    if(varRpta==true)");
         sb.AppendLine("    return !varRpta;");
         sb.AppendLine("    var ddlTipTrab = document.getElementById('" + ddlidTipoTrab.ClientID + "').value;");
         sb.AppendLine("    if(ddlTipTrab != '" + ConstTipoTrabajador.EMPLEADO + "' && ddlTipTrab != '" + ConstTipoTrabajador.EJECUTIVO + "' && ddlTipTrab != '" + ConstTipoTrabajador.OBRERO + "'){");
         sb.AppendLine("        var varRpta = isEmptyControl('" + ddlidTipoTrab.ClientID + "','Seleccione el tipo de Trabajador');");
         sb.AppendLine("        if(varRpta==true)");
         sb.AppendLine("        return !varRpta;}");
         sb.AppendLine("    break;");
         sb.AppendLine("case '" + ConstCategoriaTrab.PRESTADOR_4ta_CAT + "' :");
         sb.AppendLine("case '" + ConstCategoriaTrab.PERSONAL_TERCEROS + "' :");
         sb.AppendLine("    var varRpta = isEmptyControl('" + txtnuRUC.ClientID + "','Ingrese el numero de ruc');");
         sb.AppendLine("    if(varRpta==true)");
         sb.AppendLine("    return !varRpta;");
         sb.AppendLine("    break;");
         sb.AppendLine("case '" + ConstCategoriaTrab.PRESTADOR_MOD_FORMATIVA + "' :");
         sb.AppendLine("    var varRpta = isEmptyControl('" + ddlidTipoCenFP.ClientID + "','Seleccione el tipo de Modalidad Formativa');");
         sb.AppendLine("    if(varRpta==true)");
         sb.AppendLine("    return !varRpta;");
         sb.AppendLine("    var varRpta = isEmptyControl('" + ddlidCentroFP.ClientID + "','Seleccione el Centro de Formacion');");
         sb.AppendLine("    if(varRpta==true)");
         sb.AppendLine("    return !varRpta;");
         sb.AppendLine("    var varRpta = isEmptyControl('" + txtdsOcupa.ClientID + "','Seleccione la Ocupacion.');");
         sb.AppendLine("    if(varRpta==true)");
         sb.AppendLine("    return !varRpta;");
         sb.AppendLine("    var varRpta = isEmptyControl('" + ddlidTipoTrab.ClientID + "','Seleccione el tipo de Trabajador');");
         sb.AppendLine("    if(varRpta==true)");
         sb.AppendLine("    return !varRpta;");
         sb.AppendLine("    var ddlTipTrab = document.getElementById('" + ddlidTipoTrab.ClientID + "').value;");
         sb.AppendLine("    if(ddlTipTrab != '" + ConstTipoTrabajador.EMPLEADO + "' && ddlTipTrab != '" + ConstTipoTrabajador.EJECUTIVO + "' && ddlTipTrab != '" + ConstTipoTrabajador.OBRERO + "'){");
         sb.AppendLine("        var varRpta = isEmptyControl('" + ddlidTipoTrab.ClientID + "','Seleccione el tipo de Trabajador');");
         sb.AppendLine("        if(varRpta==true)");
         sb.AppendLine("        return !varRpta;}");
         sb.AppendLine("    break;");
         sb.AppendLine("}");
         sb.AppendLine("}");

         sb.AppendLine("menu_doPostBack('" + mnuToolbar.ClientID + "','" + mnuToolbar.UniqueID + "',key);");
         sb.AppendLine("}");

         sb.AppendLine("function onchange" + this.ddlidCateTrab.ID + "(){");
         sb.AppendLine("var ddl = document.getElementById('" + this.ddlidCateTrab.ClientID + "').value;");
         sb.AppendLine("   switch(ddl){");
         sb.AppendLine("   case '" + ConstCategoriaTrab.TRABAJADOR + "' :");
         sb.AppendLine("      document.getElementById('" + this.chkstMadreResp.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.ddlidCentroFP.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.ddlidTipoCenFP.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.ddlidCateOcup.ClientID + "').disabled = false;");
         sb.AppendLine("      document.getElementById('" + this.ddlidRegLaboral.ClientID + "').disabled = false;");
         sb.AppendLine("      document.getElementById('" + this.ddlidNivEduc.ClientID + "').disabled = false;");
         sb.AppendLine("      document.getElementById('" + this.txtdsOcupa.ClientID + "').disabled = false;");
         sb.AppendLine("      document.getElementById('" + this.txtdsOcupa.ClientID + "').disabled = false;");
         sb.AppendLine("      document.getElementById('" + this.ddlidRegPensi.ClientID + "').disabled = false;");
         sb.AppendLine("      document.getElementById('" + this.txtfeInsRegPen.ClientID + "').disabled = false;");
         sb.AppendLine("      document.getElementById('" + this.txtnuCuspp.ClientID + "').disabled = false;");
         sb.AppendLine("      document.getElementById('" + this.ddlidSctrSalud.ClientID + "').disabled = false;");
         sb.AppendLine("      document.getElementById('" + this.ddlidSctrPens.ClientID + "').disabled = false;");
         sb.AppendLine("      document.getElementById('" + this.ddlidTipoCont.ClientID + "').disabled = false;");
         sb.AppendLine("      document.getElementById('" + this.ddlidEmpEps.ClientID + "').disabled = false;");
         sb.AppendLine("      document.getElementById('" + this.ddlidSituEmple.ClientID + "').disabled = false;");
         sb.AppendLine("      document.getElementById('" + this.ddlidPeriRemu.ClientID + "').disabled = false;");
         sb.AppendLine("      document.getElementById('" + this.ddlidEstaCivil.ClientID + "').disabled = false;");
         sb.AppendLine("      document.getElementById('" + this.chkstDiscapa.ClientID + "').disabled = false;");
         sb.AppendLine("      document.getElementById('" + this.chkstJTAtipico.ClientID + "').disabled = false;");
         sb.AppendLine("      document.getElementById('" + this.txtdsOcupa.ClientID + "_button').disabled = false;");
         sb.AppendLine("      document.getElementById('" + this.chkstJTMaxima.ClientID + "').disabled = false;");
         sb.AppendLine("      document.getElementById('" + this.chkstJTHoraNoc.ClientID + "').disabled = false;");
         sb.AppendLine("      document.getElementById('" + this.chkstOtrosIng5ta.ClientID + "').disabled = false;");
         sb.AppendLine("      document.getElementById('" + this.chkstSindical.ClientID + "').disabled = false;");
         sb.AppendLine("      document.getElementById('" + this.chkst5taExo.ClientID + "').disabled = false;");
         sb.AppendLine("      document.getElementById('" + this.chkstAsigFami.ClientID + "').disabled = false;");
         sb.AppendLine("      document.getElementById('" + this.chkstSujRegAlter.ClientID + "').disabled = false;");
         sb.AppendLine("      $('#" + this.txtfeInsRegPen.ClientID + "').datepicker('enable');");
         sb.AppendLine("      document.getElementById('" + this.txtfeInsRegPen.ClientID + "').disabled = false;");
         sb.AppendLine("      var tc = $find('" + this.tabMaster.ClientID + "');");
         sb.AppendLine("      tc.get_tabs()[2].set_enabled(true);");
         sb.AppendLine("      tc.get_tabs()[3].set_enabled(true);");
         sb.AppendLine("      break;");
         sb.AppendLine("   case '" + ConstCategoriaTrab.PENSIONISTA + "' :");
         sb.AppendLine("      document.getElementById('" + this.ddlidRegLaboral.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.ddlidNivEduc.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.txtdsOcupa.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.txtdsOcupa.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.ddlidRegPensi.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.txtfeInsRegPen.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.txtnuCuspp.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.ddlidSctrSalud.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.ddlidSctrPens.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.ddlidTipoCont.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.ddlidEmpEps.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.ddlidSituEmple.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.ddlidPeriRemu.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.ddlidEstaCivil.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.chkstMadreResp.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.ddlidCentroFP.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.ddlidTipoCenFP.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.chkstDiscapa.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.chkstJTAtipico.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.txtdsOcupa.ClientID + "_button').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.chkstJTMaxima.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.chkstJTHoraNoc.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.chkstOtrosIng5ta.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.chkstSindical.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.chkst5taExo.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.chkstAsigFami.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.chkstSujRegAlter.ClientID + "').disabled = true;");
         sb.AppendLine("      $('#" + this.txtfeInsRegPen.ClientID + "').datepicker('disable');");
         sb.AppendLine("      document.getElementById('" + this.txtfeInsRegPen.ClientID + "').disabled = true;");
         sb.AppendLine("      var tc = $find('" + this.tabMaster.ClientID + "');");
         sb.AppendLine("      tc.get_tabs()[2].set_enabled(true);");
         sb.AppendLine("      tc.get_tabs()[3].set_enabled(true);");
         sb.AppendLine("      break;");
         sb.AppendLine("   case '" + ConstCategoriaTrab.PRESTADOR_4ta_CAT + "' :");
         sb.AppendLine("   case '" + ConstCategoriaTrab.PERSONAL_TERCEROS + "' :");
         sb.AppendLine("      document.getElementById('" + this.txtnuRUC.ClientID + "').disabled = false;");
         sb.AppendLine("      var tc = $find('" + this.tabMaster.ClientID + "');");
         sb.AppendLine("      tc.get_tabs()[2].set_enabled(false);");
         sb.AppendLine("      tc.get_tabs()[3].set_enabled(false);");
         sb.AppendLine("      break;");
         sb.AppendLine("   case '" + ConstCategoriaTrab.PRESTADOR_MOD_FORMATIVA + "' :");
         sb.AppendLine("      document.getElementById('" + this.ddlidRegPensi.ClientID + "').disabled = false;");
         sb.AppendLine("      document.getElementById('" + this.txtfeInsRegPen.ClientID + "').disabled = false;");
         sb.AppendLine("      document.getElementById('" + this.txtnuCuspp.ClientID + "').disabled = false;");
         sb.AppendLine("      document.getElementById('" + this.ddlidRegLaboral.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.ddlidNivEduc.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.ddlidRegPensi.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.txtfeInsRegPen.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.txtnuCuspp.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.ddlidSctrSalud.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.ddlidSctrPens.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.ddlidTipoCont.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.ddlidEmpEps.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.ddlidSituEmple.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.ddlidPeriRemu.ClientID + "').disabled = true;");
         sb.AppendLine("      document.getElementById('" + this.ddlidEstaCivil.ClientID + "').disabled = true;");
         sb.AppendLine("      $('#" + this.txtfeInsRegPen.ClientID + "').datepicker('disable');");
         sb.AppendLine("      var tc = $find('" + this.tabMaster.ClientID + "');");
         sb.AppendLine("      tc.get_tabs()[2].set_enabled(true);");
         sb.AppendLine("      tc.get_tabs()[3].set_enabled(false);");
         sb.AppendLine("      break;");
         sb.AppendLine("   };");
         sb.AppendLine("};");

         ScriptManager.RegisterStartupScript(this, this.GetType(), "ScriptRegister", sb.ToString(), true);

         this.ddlidCateTrab.Attributes.Add("onchange", "onchange" + ddlidCateTrab.ID + "()");
      }

      public void RegisterEditPopupScripts()
      {
         StringBuilder sb = new StringBuilder();

         sb.AppendLine("function validate" + this.bttOkPopupRem.ID + "(){");
         sb.AppendLine("varRpta = isEmptyControl('" + this.ddlidForPago.ClientID + "','Seleccionar la Forma de Pago.');");
         sb.AppendLine("if(varRpta==true)");
         sb.AppendLine("return !varRpta;");
         sb.AppendLine("varRpta = isEmptyControl('" + this.ddlidTipRemu.ClientID + "','Ingrese el tipo de remuneración basica.');");
         sb.AppendLine("if(varRpta==true)");
         sb.AppendLine("return !varRpta;");
         sb.AppendLine("varRpta = isEmptyControl('" + this.ddlidMoneda.ClientID + "','Ingrese la Moneda de la remuneración.');");
         sb.AppendLine("if(varRpta==true)");
         sb.AppendLine("return !varRpta;");
         sb.AppendLine("varRpta = isEmptyControl('" + this.txtmtRemu.ClientID + "','Ingrese el monto de la remuneración.');");
         sb.AppendLine("if(varRpta==true)");
         sb.AppendLine("return !varRpta;");
         sb.AppendLine("}");

         sb.AppendLine("function validate" + this.bttOkPopupAprob.ID + "(){");
         if (this.intAprobObs == _INTMNUOBSERVADO)
         {
            sb.AppendLine("varRpta = isEmptyControl('" + this.txtdsObservacion.ClientID + "','Ingrese la observacion');");
            sb.AppendLine("if(varRpta==true)");
            sb.AppendLine("return !varRpta;");
         }
         sb.AppendLine("}");


         ScriptManager.RegisterStartupScript(this, this.GetType(), "validatePopup", sb.ToString(), true);

         this.bttOkPopupRem.OnClientClick = "return validate" + bttOkPopupRem.ID + "();";
         this.bttOkPopupRem.OnClientClick = "return validate" + bttOkPopupAprob.ID + "();";
         this.bttCancelPopupRem.OnClientClick = "$find('" + this.mdlPopupRem.ClientID + "').hide();return false;";
         this.bttCancelPopupAprob.OnClientClick = "$find('" + this.mdlPopupAprob.ClientID + "').hide();return false;";

      }

      protected void bttOkPopupRem_Click(object sender, EventArgs e)
      {
         DataTable dt = (DataTable)this.DataSourceRem;
         DataRow dr = null;

         if (this.GridEditActionRem == GridEditAction.AddNew || this.GridEditActionRem == GridEditAction.Copy)
            dr = dt.NewRow();
         else
            dr = this.GridGetRowFromDataKey(this.DataSourceRem, grdListRem, this.EditRowIndexRem);

         if (this.GridEditActionRem != GridEditAction.Delete)
         {
            dr["idEmpresa"] = Session[ConstSessionVar.EMPRESA].ToString();
            dr["idPersonal"] = Request.QueryString["IdPersonal"];
            dr["idForPago"] = this.ddlidForPago.SelectedItem.Value;
            dr["dsForPago"] = this.ddlidForPago.SelectedItem.Text;
            dr["idTipoRemu"] = this.ddlidTipRemu.SelectedItem.Value;
            dr["dsTipoRemu"] = this.ddlidTipRemu.SelectedItem.Text;
            dr["idMoneda"] = this.ddlidMoneda.SelectedItem.Value;
            dr["dsMoneda"] = this.ddlidMoneda.SelectedItem.Text;
            dr["mtRemu"] = this.txtmtRemu.Text;
            dr["stAprobado"] = ConstFlagEstado.DESACTIVADO;
            dr["stAnulado"] = ConstFlagEstado.DESACTIVADO;

         }
         else
         {
            dr["stAnulado"] = ConstFlagEstado.ACTIVADO;
         }

         if (this.GridEditActionRem == GridEditAction.AddNew || this.GridEditActionRem == GridEditAction.Copy)
         {
            dt.Rows.Add(dr);
         }

         this.DataSourceRem = dt;
         grdListRem.DataSource = this.DataSourceRem;
         grdListRem.DataBind();
      }

      protected void bttOkPopupAprob_Click(object sender, EventArgs e)
      {
         if (this.FormEditAction != FormEditAction.Delete)
            this.SaveData("");
         else
            this.DeleteData();


      }

      protected void mnuToolbar_MenuItemClick(Object sender, MenuEventArgs e)
      {
         if (e.Item == null)
            return;

         switch (e.Item.Value)
         {
            case ConstMenuToolbarValue.BUTTON_SAVEOK:
               this.txtdsObservacion.Text = "";
               this.lblTitlePopupAprob.Text = "Aprobacion";
               intAprobObs = _INTMNUAPROBADO;
               mdlPopupAprob.Show();
               break;
            case ConstMenuToolbarValue.BUTTON_SAVEOBS:
               this.txtdsObservacion.Text = "";
               this.lblTitlePopupAprob.Text = "Observacion";
               intAprobObs = _INTMNUOBSERVADO;
               mdlPopupAprob.Show();
               break;
            case ConstMenuToolbarValue.BUTTON_EXIT:
               this.Response.Redirect("wfVeriPersonalBnd.aspx?Filter=1");
               break;
         }

      }

      protected void mnuGridRem_MenuItemClick(Object sender, MenuEventArgs e)
      {
         if (e.Item == null)
            return;

         switch (e.Item.Value)
         {
            case ConstMenuToolbarValue.BUTTON_NEW:
               this.GridEditActionRem = GridEditAction.AddNew;
               this.lblTitlePopup.Text = "Remuneraciones (Nuevo)";
               this.mdlPopupRem.Show();
               this.LoadDataEditPopup(grdListRem, -1);
               this.RegisterEditPopupScripts();
               break;
         }

      }

      protected void grdListRem_RowCommand(Object sender, GridViewCommandEventArgs e)
      {
         this.EditRowIndexRem = Convert.ToInt32(e.CommandArgument);

         switch (e.CommandName)
         {
            case ConstGridRowCommand.GRIDEDIT:
               this.lblTitlePopup.Text = "Remuneración (Editar)";
               this.GridEditActionRem = GridEditAction.Edit;
               this.mdlPopupRem.Show();
               this.LoadDataEditPopup(grdListRem, this.EditRowIndexRem);
               this.RegisterEditPopupScripts();
               break;
            case ConstGridRowCommand.GRIDDELETE:
               this.lblTitlePopup.Text = "Remuneración (Eliminar)";
               this.GridEditActionRem = GridEditAction.Delete;
               this.mdlPopupRem.Show();
               this.LoadDataEditPopup(grdListRem, this.EditRowIndexRem);
               this.RegisterEditPopupScripts();
               break;
         }
      }

      protected void grdListRem_RowDataBound(Object sender, GridViewRowEventArgs e)
      {
         if (e.Row.RowType == DataControlRowType.DataRow)
         {
            String strRI = e.Row.RowIndex.ToString();

            ImageButton bttedit = (ImageButton)e.Row.FindControl("grdBtt" + ConstGridRowCommand.GRIDEDIT);
            ImageButton bttdelete = (ImageButton)e.Row.FindControl("grdBtt" + ConstGridRowCommand.GRIDDELETE);

            if (e.Row.Cells[_GRDLIST_STANULADOREM].Text == ConstFlagEstado.ACTIVADO)
            {
               e.Row.ForeColor = System.Drawing.Color.Red;
               bttedit.ImageUrl = "../Images/Icons/Disabled/Edit.png";
               bttdelete.ImageUrl = "../Images/Icons/Disabled/Delete.png";
            }
            else
            {
               e.Row.ForeColor = System.Drawing.Color.Green;

            }
         }
      }

      protected void ddlidUNegocio_SelectedIndexChanged(object sender, EventArgs e)
      {
         ddlidCCosto.Items.Clear();
         EUNegocio objEUNeg = new EUNegocio();
         MGBOQry.IUNegocio objBOUNego = (MGBOQry.IUNegocio)WCFHelper.GetObject<MGBOQry.IUNegocio>(typeof(MGBOQry.UNegocio));
         objEUNeg.IdEmpresa = Session[ConstSessionVar.EMPRESA].ToString();
         objEUNeg.IdUNegocio = ddlidUNegocio.SelectedItem.Value;
         DataTable dt = objBOUNego.GetCCostoXUNegocio(objEUNeg);
         WebHelper.LoadListControl(ddlidCCosto, dt, "dsCCosto", "idCCosto", true, true);
      }

      public override void LoadDataEditPopup(GridView grid, int rowIndex)
      {
         this.ClearEditPopup();
         //this.LockControlsPopup();

         if (grid == grdListRem)
         {
            DataRow dr = this.GridGetRowFromDataKey(this.DataSourceRem, grdListRem, rowIndex);

            if (dr == null)
               return;

            WebHelper.RowToControl(dr, "idForPago", ddlidForPago);
            WebHelper.RowToControl(dr, "idTipoRemu", ddlidTipRemu);
            WebHelper.RowToControl(dr, "idMoneda", ddlidMoneda);
            WebHelper.RowToControl(dr, "mtRemu", txtmtRemu);
         }

      }

      public new void ClearEditPopup()
      {
         this.txtmtRemu.Text = "";
      }

      public void LockControlsPopup()
      {
         switch (this.GridEditAction)
         {
            case GridEditAction.AddNew:
            case GridEditAction.Edit:

               break;
            case GridEditAction.Delete:
               this.ddlidForPago.Enabled = false;
               this.ddlidTipRemu.Enabled = false;
               this.ddlidMoneda.Enabled = false;
               this.txtmtRemu.Enabled = false;
               break;
         }
      }

      public override void SaveData(String key)
      {
         if (this.ValidateData() == false)
            return;

         IEntityBase objE = (IEntityBase)this.CreateEntitySet();

         IBOUpdate objPro = (IBOUpdate)WCFHelper.GetObject<IBOUpdate>(typeof(RHBOMnt.Personal));

         String[] strRet = objPro.UpdateData(objE);
         String strMsg = "";

         switch (this.FormEditAction)
         {

            case FormEditAction.AddNew:
            case FormEditAction.Copy:
               strMsg = "Se ha registrado el Personal : " + strRet[0].ToString();
               break;
            default:
               strMsg = "Se ha modificado el Personal : " + txtidPersonal.Text;
               break;
         }
         this.hdnMsgOPB.Value = this.CreatePostbackMessage("CORRECTO", strMsg, TypeMessageAlert.correct, false, "wfPersonalBnd.aspx?Filter=1");
      }

      public override void DeleteData()
      {
         IEntityBase objE = (IEntityBase)this.CreateEntitySet();
         IBOUpdate objPro = (IBOUpdate)WCFHelper.GetObject<IBOUpdate>(typeof(RHBOMnt.Personal));
         objPro.DeleteData(objE);

         this.hdnMsgOPB.Value = this.CreatePostbackMessage("CORRECTO", "Se anulo el Personal  : " + txtidPersonal.Text, TypeMessageAlert.correct, false, "wfPersonalBnd.aspx?Filter=1");

      }

      public override Object CreateEntitySet()
      {
         EPersonal objE = new EPersonal();

         if (this.FormEditAction == FormEditAction.AddNew || this.FormEditAction == FormEditAction.Copy)
            objE.EntityState = EntityState.Added;
         else
         {
            IBOQuery objBO = (IBOQuery)WCFHelper.GetObject<IBOQuery>(typeof(RHBOQry.Personal));
            objE.IdEmpresa = Session[ConstSessionVar.EMPRESA].ToString();
            objE.IdPersonal = txtidPersonal.Text;
            objE = (EPersonal)objBO.GetByKey(objE);

            if (this.FormEditAction == FormEditAction.Edit)
               objE.EntityState = EntityState.Modified;
            if (this.FormEditAction == FormEditAction.Delete)
               objE.EntityState = EntityState.Deleted;

         }

         objE.IdEmpresa = Session[ConstSessionVar.EMPRESA].ToString();

         WebHelper.ControlToEntity(txtidPersonal, objE, "IdPersonal");
         WebHelper.ControlToEntity(ddlidUNegocio, objE, "IdUNegocio");
         WebHelper.ControlToEntity(ddlidCCosto, objE, "IdCCosto");
         WebHelper.ControlToEntity(txtfeNacimiento, objE, "FeNacimien");
         WebHelper.ControlToEntity(ddlidSexo, objE, "IdSexo");
         WebHelper.ControlToEntity(ddlidEstable, objE, "IdEstable");
         WebHelper.ControlToEntity(txtnuFotocheck, objE, "NuFotocheck");
         WebHelper.ControlToEntity(ddlidCateOcup, objE, "IdCateOcupa");
         WebHelper.ControlToEntity(ddlidCateTrab, objE, "IdCateTrab");
         WebHelper.ControlToEntity(ddlidRegLaboral, objE, "IdRegLaboral");
         WebHelper.ControlToEntity(ddlidTipoTrab, objE, "IdTipoTrab");
         WebHelper.ControlToEntity(ddlidNivEduc, objE, "IdNivEduc");
         WebHelper.ControlToEntity(txtidOcupa, objE, "IdOcupa");
         WebHelper.ControlToEntity(ddlidRegPensi, objE, "IdRegPensi");

         if (txtfeInsRegPen.Text != "")
            WebHelper.ControlToEntity(txtfeInsRegPen, objE, "FeInscRegPen");
         else
            objE.FeInscRegPen = null;

         WebHelper.ControlToEntity(txtnuCuspp, objE, "NuCuspp");
         WebHelper.ControlToEntity(ddlidSctrSalud, objE, "IdSctrSalud");
         WebHelper.ControlToEntity(ddlidSctrPens, objE, "IdSctrPens");
         WebHelper.ControlToEntity(ddlidTipoCont, objE, "IdTipoCont");
         WebHelper.ControlToEntity(ddlidPeriRemu, objE, "IdPeriRemu");
         objE.IdSegMedi = "";
         WebHelper.ControlToEntity(ddlidEmpEps, objE, "IdEmpEps");
         WebHelper.ControlToEntity(ddlidSituEmple, objE, "IdSituEmple");
         WebHelper.ControlToEntity(ddlidTipoRemu, objE, "IdTipoRemu");
         if (txtfeIngPla.Text != "")
            WebHelper.ControlToEntity(txtfeIngPla, objE, "FeIngpla");
         else
            objE.FeIngpla = null;

         if (txtfeCese.Text != "")
            WebHelper.ControlToEntity(txtfeCese, objE, "FeCese");
         else
            objE.FeCese = null;

         WebHelper.ControlToEntity(ddlidMotivFin, objE, "IdMotivFin");
         WebHelper.ControlToEntity(ddlidTipoCenFP, objE, "IdTipoCenFP");
         WebHelper.ControlToEntity(ddlidCentroFP, objE, "IdCentroFP");
         WebHelper.ControlToEntity(ddlidEstaCivil, objE, "IdEstaCivil");
         WebHelper.ControlToEntity(ddlidBcoAbono, objE, "IdBcoAbono");
         WebHelper.ControlToEntity(ddlidTipoCtaAbono, objE, "IdTipoCtaAbo");
         WebHelper.ControlToEntity(txtnuctaAbono, objE, "NuCtaAbono");
         WebHelper.ControlToEntity(ddlidBcoCts, objE, "IdBcoCts");
         WebHelper.ControlToEntity(txtnuCtaCts, objE, "NuCtaCts");
         WebHelper.ControlToEntity(chkstEsSalud, objE, "StEsSalud");
         WebHelper.ControlToEntity(chkstDomiciliado, objE, "StDomiciliado");
         WebHelper.ControlToEntity(chkstDomiciliado, objE, "StDiscapa");
         WebHelper.ControlToEntity(chkstSujRegAlter, objE, "StSujRegAlter");
         WebHelper.ControlToEntity(chkstJTMaxima, objE, "StJTMaxima");
         WebHelper.ControlToEntity(chkstJTHoraNoc, objE, "StJTHoraNoc");
         WebHelper.ControlToEntity(chkstJTAtipico, objE, "StJTAtipico");
         WebHelper.ControlToEntity(chkstOtrosIng5ta, objE, "StOtrosIng5ta");
         WebHelper.ControlToEntity(chkstSindical, objE, "StSindical");
         WebHelper.ControlToEntity(chkst5taExo, objE, "St5taExon");
         WebHelper.ControlToEntity(chkstMadreResp, objE, "StMadreResp");
         WebHelper.ControlToEntity(chkstAsigFami, objE, "StAsigFami");
         WebHelper.ControlToEntity(ddlidTipoSangre, objE, "IdTipoSangre");
         WebHelper.ControlToEntity(txtdsEnfermedad, objE, "DsEnfermedad");
         WebHelper.ControlToEntity(txtdsAlergia, objE, "DsAlergia");
         WebHelper.ControlToEntity(txtdsPriAuxilios, objE, "DsPriAuxilios");
         WebHelper.ControlToEntity(txtnuTalla, objE, "NuTalla");
         WebHelper.ControlToEntity(txtnuPeso, objE, "NuPeso");
         WebHelper.ControlToEntity(txtdsTallaCalza, objE, "DsTallaCalza");
         WebHelper.ControlToEntity(txtdsTallaPanta, objE, "DsTallaPanta");
         WebHelper.ControlToEntity(txtdsTallaCamisa, objE, "DsTallaCamisa");
         WebHelper.ControlToEntity(txtdsClubSoDe, objE, "DsClubSoDe");
         WebHelper.ControlToEntity(txtdsHobby, objE, "DsHobby");
         WebHelper.ControlToEntity(txtdsReligion, objE, "DsReligion");

         if (this.intAprobObs == _INTMNUAPROBADO)
            objE.IdEstado = ConstEstadoRegPersonal.VERIFICADO;
         else
            objE.IdEstado = ConstEstadoRegPersonal.OBSERVADO;
         objE.StAnulado = ConstFlagEstado.DESACTIVADO;

         ECliProv objECli = new ECliProv();
         if (this.FormEditAction == FormEditAction.AddNew || this.FormEditAction == FormEditAction.Copy)
            objECli.EntityState = EntityState.Added;
         else
         {
            IBOQuery objBOCli = (IBOQuery)WCFHelper.GetObject<IBOQuery>(typeof(MGBOQry.CliProv));
            objECli.IdCliProv = objE.IdCliProv;
            objECli = (ECliProv)objBOCli.GetByKey(objECli);

            if (this.FormEditAction == FormEditAction.Edit)
               objECli.EntityState = EntityState.Modified;
            if (this.FormEditAction == FormEditAction.Delete)
               objECli.EntityState = EntityState.Deleted;

         }

         WebHelper.ControlToEntity(hdnidCliProv, objECli, "IdCliProv");

         objECli.IdTipoCliProv = ConstTipoCliProv.PROVEEDOR;
         objECli.IdNatuJuri = ConstTipoPersona.NATURAL;

         objECli.DsRazSocial = txtdsAPaterno.Text + " " + txtdsAMaterno.Text + " " + txtdsNombres.Text;

         WebHelper.ControlToEntity(txtdsAPaterno, objECli, "DsAPaterno");
         WebHelper.ControlToEntity(txtdsAMaterno, objECli, "DsAMaterno");
         WebHelper.ControlToEntity(txtdsNombres, objECli, "DsNombres");
         WebHelper.ControlToEntity(hdnidPais, objECli, "IdPaisEmite");
         WebHelper.ControlToEntity(ddlidTDocIden, objECli, "IdTDocIden");
         WebHelper.ControlToEntity(txtnuDocIden, objECli, "NuDocIden");
         WebHelper.ControlToEntity(txtfeVctoDoIde, objECli, "FeVenDocIden");
         WebHelper.ControlToEntity(hdnidPais, objECli, "IdPais");
         WebHelper.ControlToEntity(hdnidDepa, objECli, "IdDepa");
         WebHelper.ControlToEntity(hdnidProv, objECli, "IdProv");
         WebHelper.ControlToEntity(hdnidDist, objECli, "IdDist");
         WebHelper.ControlToEntity(ddlidTipoVia, objECli, "IdTipoVia");
         WebHelper.ControlToEntity(txtdsNombreVia, objECli, "DsNombreVia");
         WebHelper.ControlToEntity(txtnuVia, objECli, "NuVia");
         WebHelper.ControlToEntity(txtnuDpto, objECli, "NuDpto");
         WebHelper.ControlToEntity(txtnuInterior, objECli, "NuInterior");
         WebHelper.ControlToEntity(txtdsManzana, objECli, "DsManzana");
         WebHelper.ControlToEntity(txtdsLote, objECli, "DsLote");
         WebHelper.ControlToEntity(txtdsKilometro, objECli, "DsKilometro");
         WebHelper.ControlToEntity(txtdsBlock, objECli, "DsBlock");
         WebHelper.ControlToEntity(txtdsEtapa, objECli, "DsEtapa");
         WebHelper.ControlToEntity(ddlidTipoZona, objECli, "IdTipoZona");
         WebHelper.ControlToEntity(txtdsNombZona, objECli, "DsNombZona");
         WebHelper.ControlToEntity(txtdsReferen, objECli, "DsReferen");
         WebHelper.ControlToEntity(txtnuTelf, objECli, "NuTelf");
         WebHelper.ControlToEntity(txtnufax, objECli, "NuFax");
         WebHelper.ControlToEntity(txtdsEmail, objECli, "DsEmail");
         WebHelper.ControlToEntity(txtdsWeb, objECli, "DsWeb");

         objECli.StRegSis = ConstFlagEstado.DESACTIVADO;

         EPerFoto objEArch = this.CrearEntidadArchivo();

         DataTable dtRem = (DataTable)this.DataSourceRem;
         this.ClearDeletedRow(this.DataSourceRem, "stAnulado");
         IList<EPerRemu> colEPerRem = new List<EPerRemu>();

         if (this.FormEditAction == FormEditAction.Delete)
         {
            foreach (DataRow dr in dtRem.Rows)
            {
               this.MarkDeletedRow(dr, "stAnulado");
            }
         }


         for (int intTypeUpd = 0; intTypeUpd <= 1; intTypeUpd++)
         {
            DataTable dtChange = null;
            if (intTypeUpd == 0)
               dtChange = dtRem.GetChanges(DataRowState.Added);
            else
               dtChange = dtRem.GetChanges(DataRowState.Modified);


            if (dtChange != null)
            {
               foreach (DataRow drDet in dtChange.Rows)
               {
                  EPerRemu objRDet = DataHelper.CopyDataRowToEntity<EPerRemu>(drDet, typeof(EPerRemu));

                  if (drDet.RowState == DataRowState.Added)
                     objRDet.EntityState = EntityState.Added;

                  if (drDet.RowState == DataRowState.Modified)
                  {
                     if (objRDet.StAnulado == ConstFlagEstado.DESACTIVADO)
                        objRDet.EntityState = EntityState.Modified;
                     else
                        objRDet.EntityState = EntityState.Deleted;
                  }

                  colEPerRem.Add(objRDet);
               }
            }
         }

         EPersonalSet objESet = new EPersonalSet();
         objESet.Personal = objE;
         objESet.CliProv = objECli;
         objESet.PerFoto = objEArch;
         objESet.ColPerRemu = colEPerRem;


         EPerHistoAprob objEHisto = new EPerHistoAprob();
         objEHisto.EntityState = EntityState.Added;
         objEHisto.IdEmpresa = Session[ConstSessionVar.EMPRESA].ToString();
         objEHisto.IdPersonal = txtidPersonal.Text;
         if (this.intAprobObs == _INTMNUAPROBADO)
            objEHisto.IdEstado = ConstEstadoRegPersonal.VERIFICADO;
         else
            objEHisto.IdEstado = ConstEstadoRegPersonal.OBSERVADO;

         objEHisto.IdUser = Session[ConstSessionVar.USERID].ToString();
         objEHisto.FeAccion = DateTime.Now;
         objEHisto.DsObservacion = txtdsObservacion.Text;
         objESet.HistoAprob = objEHisto;


         return objESet;
      }

      private EPerFoto CrearEntidadArchivo()
      {
         HttpPostedFile objFile = this.fuidFotografia.PostedFile;

         if (objFile == null)
            return null;

         if (objFile.ContentLength == 0)
            return null;

         //byte[] objStream = new byte[objFile.ContentLength];
         //objFile.InputStream.Read(objStream, 0, objFile.ContentLength);
         //objFile.InputStream.Close();

         byte[] objStream = this.GetNewByteImage(this.fuidFotografia);

         EPerFoto objEArch = new EPerFoto();

         if (_STFOTO == ConstFlagEstado.DESACTIVADO)
            objEArch.EntityState = EntityState.Added;
         else
            objEArch.EntityState = EntityState.Modified;

         objEArch.IdEmpresa = Session[ConstSessionVar.EMPRESA].ToString();
         objEArch.IdPersonal = txtidPersonal.Text;
         objEArch.DsNombreArch = Path.GetFileName(objFile.FileName);
         objEArch.IdFotografia = objStream;

         return objEArch;

      }

      private byte[] GetNewByteImage(FileUpload fileUpload)
      {
         Bitmap cropImage = null;
         byte[] bmpBytes = null;
         try
         {
            Stream imStream = fileUpload.PostedFile.InputStream;
            Bitmap imOriginal = new Bitmap(imStream);
            cropImage = new Bitmap(imOriginal, 132, 170);

            MemoryStream ms = new MemoryStream();
            cropImage.Save(ms, ImageFormat.Jpeg);

            bmpBytes = ms.GetBuffer();
            cropImage.Dispose();
            ms.Close();

         }
         catch (System.Net.WebException)
         {
         }
         return bmpBytes;
      }

      public override void LockControls()
      {
         if (this.ddlidCateTrab.SelectedItem.Value != "")
            this.ddlidCateTrab.Enabled = false;

         switch (this.ddlidCateTrab.SelectedItem.Value)
         {
            case ConstCategoriaTrab.TRABAJADOR:
               this.chkstMadreResp.Enabled = false;
               this.ddlidCentroFP.Enabled = false;
               this.ddlidTipoCenFP.Enabled = false;
               this.ddlidCateOcup.Enabled = true;
               this.ddlidRegLaboral.Enabled = true;
               this.ddlidNivEduc.Enabled = true;
               this.txtdsOcupa.Enabled = true;
               this.txtdsOcupa.Enabled = true;
               this.ddlidRegPensi.Enabled = true;
               this.txtfeInsRegPen.Enabled = true;
               this.txtnuCuspp.Enabled = true;
               this.ddlidSctrSalud.Enabled = true;
               this.ddlidSctrPens.Enabled = true;
               this.ddlidTipoCont.Enabled = true;
               this.ddlidEmpEps.Enabled = true;
               this.ddlidSituEmple.Enabled = true;
               this.ddlidPeriRemu.Enabled = true;
               this.ddlidEstaCivil.Enabled = true;
               this.chkstDiscapa.Enabled = true;
               this.chkstJTAtipico.Enabled = true;
               this.txtdsOcupa.ReadOnly = false;
               this.chkstJTMaxima.Enabled = true;
               this.chkstJTHoraNoc.Enabled = true;
               this.chkstOtrosIng5ta.Enabled = true;
               this.chkstSindical.Enabled = true;
               this.chkst5taExo.Enabled = true;
               this.chkstAsigFami.Enabled = true;
               this.chkstSujRegAlter.Enabled = true;
               this.txtfeInsRegPen.ReadOnly = false;
               this.txtfeInsRegPen.Enabled = true;
               this.tabChildPrinci.Enabled = true;
               this.tabChildDComple.Enabled = true;
               break;
            case ConstCategoriaTrab.PENSIONISTA:
               this.ddlidRegLaboral.Enabled = false;
               this.ddlidNivEduc.Enabled = false;
               this.txtdsOcupa.Enabled = false;
               this.txtdsOcupa.Enabled = false;
               this.ddlidRegPensi.Enabled = false;
               this.txtfeInsRegPen.Enabled = false;
               this.txtnuCuspp.Enabled = false;
               this.ddlidSctrSalud.Enabled = false;
               this.ddlidSctrPens.Enabled = false;
               this.ddlidTipoCont.Enabled = false;
               this.ddlidEmpEps.Enabled = false;
               this.ddlidSituEmple.Enabled = false;
               this.ddlidPeriRemu.Enabled = false;
               this.ddlidEstaCivil.Enabled = false;
               this.chkstMadreResp.Enabled = false;
               this.ddlidCentroFP.Enabled = false;
               this.ddlidTipoCenFP.Enabled = false;
               this.chkstDiscapa.Enabled = false;
               this.chkstJTAtipico.Enabled = false;
               this.txtdsOcupa.ReadOnly = true;
               this.chkstJTMaxima.Enabled = false;
               this.chkstJTHoraNoc.Enabled = false;
               this.chkstOtrosIng5ta.Enabled = false;
               this.chkstSindical.Enabled = false;
               this.chkst5taExo.Enabled = false;
               this.chkstAsigFami.Enabled = false;
               this.chkstSujRegAlter.Enabled = false;
               this.txtfeInsRegPen.ReadOnly = true;
               this.txtfeInsRegPen.Enabled = false;
               this.tabChildPrinci.Enabled = true;
               this.tabChildDComple.Enabled = true;
               break;
            case ConstCategoriaTrab.PRESTADOR_4ta_CAT:
            case ConstCategoriaTrab.PERSONAL_TERCEROS:
               this.txtnuRUC.Enabled = true;
               this.tabChildPrinci.Enabled = false;
               this.tabChildDComple.Enabled = false;
               break;
            case ConstCategoriaTrab.PRESTADOR_MOD_FORMATIVA:
               this.ddlidRegPensi.Enabled = true;
               this.txtfeInsRegPen.Enabled = true;
               this.txtnuCuspp.Enabled = true;
               this.ddlidRegLaboral.Enabled = false;
               this.ddlidNivEduc.Enabled = false;
               this.ddlidRegPensi.Enabled = false;
               this.txtfeInsRegPen.Enabled = false;
               this.txtnuCuspp.Enabled = false;
               this.ddlidSctrSalud.Enabled = false;
               this.ddlidSctrPens.Enabled = false;
               this.ddlidTipoCont.Enabled = false;
               this.ddlidEmpEps.Enabled = false;
               this.ddlidSituEmple.Enabled = false;
               this.ddlidPeriRemu.Enabled = false;
               this.ddlidEstaCivil.Enabled = false;
               this.txtfeInsRegPen.ReadOnly = true;
               this.tabChildPrinci.Enabled = true;
               this.tabChildDComple.Enabled = false;
               break;
         }

      }

   }
}